package ttsolver.input;

import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;

import ttsolver.enums.Direction;
import ttsolver.variables.Variable;
import ttsolver.variables.Xmove;

public class Node {
	private Long id;
	// private Hashtable<Long, Arc> inboundArcList;
	// private Hashtable<Long, Arc> outboundArcList;
	private List<Node> nextNodes;
	private List<Node> prevNodes;
	private Hashtable<Long, List<Variable>> inboundArcs;
	private List<Variable> inLinks;
	private int milepost;

	public Node() {
		nextNodes = new ArrayList<Node>();
		prevNodes = new ArrayList<Node>();
		inboundArcs = new Hashtable<Long, List<Variable>>();
		inLinks = new ArrayList<Variable>();
	}

	public Node(Long id) {
		this.id = id;
		nextNodes = new ArrayList<Node>();
		prevNodes = new ArrayList<Node>();
		inboundArcs = new Hashtable<Long, List<Variable>>();
		inLinks = new ArrayList<Variable>();
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public List<Node> getNextNodes() {
		return nextNodes;
	}
	
	public List<Node> getNextNodes(Direction dir){
		if (dir == Direction.EASTBOUND)
			return nextNodes;
		else
			return prevNodes;
	}

	public void setNextNodes(List<Node> nextNodes) {
		this.nextNodes = nextNodes;
	}

	public List<Node> getPrevNodes() {
		return prevNodes;
	}
	
	public List<Node> getPrevNodes(Direction dir){
		if (dir == Direction.EASTBOUND)
			return prevNodes;
		else
			return nextNodes;
	}

	public void setPrevNodes(List<Node> prevNodes) {
		this.prevNodes = prevNodes;
	}

	public Hashtable<Long, List<Variable>> getInboundArcs() {
		return inboundArcs;
	}

	public void setInboundArcs(Hashtable<Long, List<Variable>> list) {
		this.inboundArcs = list;
	}
	
	

	public int getMilepost() {
		return milepost;
	}

	public void setMilepost(int milepost) {
		this.milepost = milepost;
	}

	public void addInboundArc(Long idTrain, Variable var) {
		if (inboundArcs.get(idTrain) == null)
			inboundArcs.put(idTrain, new ArrayList<Variable>());
		inboundArcs.get(idTrain).add(var);
	}

	public List<Variable> getInboundArcs(Long idTrain) {
		if (inboundArcs.get(idTrain) != null)
			return inboundArcs.get(idTrain);
		return new ArrayList<Variable>();
	}

	public List<Variable> getInLinks() {
		return inLinks;
	}

	public void setInLinks(List<Variable> inLinks) {
		this.inLinks = inLinks;
	}
	
	
}
